package com.mystore.util;

import java.util.HashMap;
import java.util.Map;

public class GoodUtil {
    private static Map<String,Object> good;

    public Map<String,Object> getInstance() {
        if(good==null){
            return new HashMap<>();
        }else{
            return good;
        }
    }


    /**
     * 添加到购物车
     * @param object
     */
    public void addCart(String gid,Object object){
        good.put(gid,object);
    }

    /**
     * 移除购物车
     * @param gid
     */
    public void removeCart(String gid){
        good.remove(gid);
    }

    /**
     * 是否已经存在
     * @param gid
     * @return
     */
    public Boolean isContains(String gid){
        return good.containsKey(gid);
    }
}
